//    Copyright (C) Kherty.  All rights reserved.
using System.Diagnostics.Contracts;
using System.Reflection;
using OpenLS.Core.Notification;
using OpenLS.Core.Serialization;
using OpenLS.Drawing;
using System.ComponentModel;

namespace OpenLS.Chart
{
    public class DisplayUnitsLabel : ViewModelBase, IOfficeXmlSerializable, IShape
    {
        private Layout layout;
        private ShapeProperties spPr;

        private Text tx;
        private TextBody txPr;

        public Layout Layout
        {
            get { return layout; }
            set { layout = value;notifyPropertyChanged("Layout"); }
        }

        public Text Text
        {
            get { return tx; }
            set { tx = value;notifyPropertyChanged("Text"); }
        }

        public ShapeProperties ShapeProperties
        {
            get { return spPr; }
            set { spPr = value; notifyPropertyChanged("ShapeProperties");}
        }

        public TextBody TextProperties
        {
            get
            {
              //  if (txPr == null)
                //    txPr = new TextBody();
                return txPr;
            }
            set { txPr = value;
                notifyPropertyChanged("TextProperties"); }
        }


        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.Read("dispUnitsLbl"))
            {
                Layout = c.ReadOptionalElement<Layout>("layout");
                Text = c.ReadOptionalElement<Text>("tx");
                ShapeProperties = c.ReadOptionalElement<ShapeProperties>("spPr"); //\\namespace
                TextProperties = c.ReadOptionalElementAs<TextBody>("txPr");
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("dispUnitsLbl"))
            {
                c.WriteOptionalElement(Layout);
                c.WriteOptionalElement(Text);
                c.WriteOptionalElement(ShapeProperties); //\\namespace
                c.WriteOptionalElementAs(TextProperties, "txPr");
            }
        }

    }
}